import {defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'
import ReactivityTransform from '@vue-macros/reactivity-transform/vite';
import AutoImport from "unplugin-auto-import/vite";
import * as path from "node:path";

// https://vite.dev/config/
export default defineConfig(({ mode }) => {
    // 获取`.env`环境配置文件
    const env = loadEnv(mode, process.cwd());
    return {
        plugins: [
            vue(),
            ReactivityTransform(),
            AutoImport({
                imports: ["vue", "vue-router"],
            }),
        ],
        server: {
            host: 'localhost',
            port: Number('5178'),
            // 运行时自动打开浏览器
            open: true,
            proxy: {
                "/res" : {
                    target: 'http://127.0.0.1:8080',
                    changeOrigin: true,
                }
            }
        },

        resolve: {
            alias: {
                "@": path.resolve(__dirname, "src"),
            },
        }
    }
})
